<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../include/admincontent.jsp" %>
<link rel="stylesheet" href="../../resources/js/plugins/layui/css/layui.css" />
<div id="popup">
    <input style="display: none" id="uid" value= ${uid}>
    <input type="hidden" name="pid" value="${pid}"/>
    <input type="hidden" name="fid" value="${fid}"/>
    <input type="hidden" name="deptcode" value="${deptcode}"/>
    <form id="titleForm" action="">
        <div style="padding: 20px;">
            <%--<div style="display: flex;">--%>
                <div style="width: 98px;margin-bottom: 5px">
                    应聘岗位：
                </div>
                <div>
                    <div class="layui-inline">
                        <input style="vertical-align: middle" type="checkbox" id="checkAll" onclick="iselect()">全选</input>
                    </div>
                    <c:forEach var="projectinfojobs" items="${jobs}" varStatus="item" >
                        <c:choose>
                            <c:when test="${projectinfojobs!=null}">
                                <div class="layui-inline">
                                    <input type="checkbox" name="projectinfojobs" style="margin-top: 5px;vertical-align: top;"
                                           value="${projectinfojobs.jobname}">${projectinfojobs.jobname}</input>
                                </div>
                            </c:when>
                        </c:choose>
                    </c:forEach>
                </div>
            <%--</div>--%>
            <div class="layui-form-item" style="margin-top: 15px;clear: both">
                <div class="layui-input-block" style="text-align: center; margin-left: 0px;">
                    <button type="button" class="layui-btn" id="bs_outsign">导出笔试签到</button>
                    <button type="button" class="layui-btn" id="bs_outpeopleinfo">导出人员信息</button>
                    <button type="button" class="layui-btn" id="bs_outseatlabel">导出座位标签</button>
                    <button type="button" class="layui-btn" id="resume_output">导出表格数据</button>
                </div>
                <div class="layui-input-block" style="text-align: center; margin-left: 0px;margin-top: 10px">
                    <button type="button" class="layui-btn" id="bs_outplan">导出笔试安排</button>
                    <button type="button" class="layui-btn" id="bs_outnum">导出准考证</button>
                </div>
                <div class="layui-input-block" style="text-align: center; margin-left: 0px;margin-top: 10px">
                    <button type="button" class="layui-btn" id="bs_in">导入笔试成绩</button>
                </div>
            </div>
        </div>
    </form>
</div>
<script src="../../resources/js/plugins/layui/layui.all.js" type="text/javascript"></script>
<script>
    var form;
    layui.use('form', function(){
        form = layui.form;
        //各种基于事件的操作，下面会有进一步介绍
        form.render();
    });
 /*   $(function () {
        $('#btn_export').click(function () {
            var box = document.getElementsByName("projectinfojobs");
            var objArray = box.length;
            var apiContentStr="";
            for(var i=0;i<objArray;i++){
                if(box[i].checked == true){
                    apiContentStr += box[i].value+",";
                }
            }
            apiContentStr = apiContentStr.substring(0, apiContentStr.length-1);
            if (apiContentStr.length==0){
                layer.msg('请选择一个应聘职位');
            } else if(${tag}!=3){
                location.href = '/Do/BS/exportsign?pid=${pid}&fid=${fid}&tag=${tag}&jname='+apiContentStr;
            }
            window.event.returnValue=false;
        });
        form.render();
    });*/


    //导出人员信息
    $('#bs_outpeopleinfo').click(function () {
        var box = document.getElementsByName("projectinfojobs");
        var objArray = box.length;
        var apiContentStr="";
        for(var i=0;i<objArray;i++){
            if(box[i].checked == true){
                apiContentStr += box[i].value+",";
            }
        }
        apiContentStr = apiContentStr.substring(0, apiContentStr.length-1);
        if (apiContentStr.length==0){
            layer.msg('请选择一个应聘职位',{icon:2,time:2000});
        } else{
            location.href = '/Do/BS/exportpeopleinfo?pid=${pid}&fid=${fid}&jname='+apiContentStr;
        }
        window.event.returnValue=false;
    });

    //导出笔试签到
    $('#bs_outsign').click(function () {
        var box = document.getElementsByName("projectinfojobs");
        var objArray = box.length;
        var apiContentStr="";
        for(var i=0;i<objArray;i++){
            if(box[i].checked == true){
                apiContentStr += box[i].value+",";
            }
        }
        apiContentStr = apiContentStr.substring(0, apiContentStr.length-1);
        if (apiContentStr.length==0){
            layer.msg('请选择一个应聘职位',{icon:2,time:2000});
        } else{
            location.href = '/Do/BS/exportsign?pid=${pid}&fid=${fid}&jname='+apiContentStr;
        }
        window.event.returnValue=false;
    });

    //导出笔试座位标签
    $('#bs_outseatlabel').click(function () {
        var box = document.getElementsByName("projectinfojobs");
        var objArray = box.length;
        var apiContentStr="";
        for(var i=0;i<objArray;i++){
            if(box[i].checked == true){
                apiContentStr += box[i].value+",";
            }
        }
        apiContentStr = apiContentStr.substring(0, apiContentStr.length-1);
        if (apiContentStr.length==0){
            layer.msg('请选择一个应聘职位',{icon:2,time:2000});
        } else{
            location.href = '/Do/BS/exportseatlabel?pid=${pid}&fid=${fid}&jname='+apiContentStr;
        }
        window.event.returnValue=false;
    });

    function iselect(){ //其中函数字不能为select 其为JS保留字
        var ids = document.getElementsByName("projectinfojobs");
        var all = document.getElementById("checkAll");
        for(var i=0;i<ids.length;i++){
            ids[i].checked=all.checked;
        }
    }

    //导出表格数据
    $('#resume_output').click(function () {
        var pids = GetQueryString("pid").toString();
        if((pids.substr(0, 2) === "C_")||(pids.substr(0, 2) === "E_"))
            openpLayer('请选择要导出的字段', '/ExcelDown/DownDoResumeBySearch?pid=${pid}&fid=${fid}&deptcode=${deptcode}&'+$('#sform').serialize(), '60%', '70%');
        else
            openpLayer('请选择要导出的字段', '/ExcelDown/DownDoResume?pid=${pid}&fid=${fid}&deptcode=${deptcode}&'+$('#sform').serialize(), '60%', '70%');
    });

    //导出准考证
    $('#bs_outnum').click(function () {
        uidCounts = GetQueryString('uidCount');

        if(uidCounts == 0){
            layer.msg('请先选择需要导出的数据!',{icon:2,time:2000});
        }else if(uidCounts==1){
            var uids = GetQueryString('uid');
            location = '/Do/BS/exportticket?pid=${pid}&fid=${fid}&uid=' + uids;
        }else{
            var uids = getUrlVal('uid');

            var uidt = '';
            for(var i=0;i<uids.length;i++) {
                uidt += '&uid=' + uids[i];
            }
            location = '/Do/BS/exportticket?pid=${pid}&fid=${fid}' + uidt;
        }
    });

    //导出笔试安排
    $('#bs_outplan').click(function () {
        uidCounts = GetQueryString('uidCount');

        if(uidCounts == 0){
            layer.msg('请先选择需要导出的数据!',{icon:2,time:2000});
        }else if(uidCounts==1){
            var uids = GetQueryString('uid');
            location = '/Do/BS/exportplan?pid=${pid}&fid=${fid}&uid=' + uids;
        }else{
            var uids = getUrlVal('uid');

            var uidt = '';
            for(var i=0;i<uids.length;i++) {
                uidt += '&uid=' + uids[i];
            }

            location = '/Do/BS/exportplan?pid=${pid}&fid=${fid}' + uidt;
        }
    });
    //导入成绩
    $('#bs_in').click(function () {
        openpLayer('导入笔试成绩', '/Do/BS/import?pid=${pid}&fid=${fid}&deptcode=${deptcode}', '80%', '50%');
    });
</script>